<?php
/*
 * 
 */
?>
<?php if($this->webChatQcode): ?>
<div style="width:350px; padding: 80px 0px; text-align: center; margin: 0px auto">
    <h2 style="font-family:'Microsoft Yahei';font-size: 20px; margin-bottom: 20px;">微信登录</h2>
    
    <div><img src="<?php echo $this->webChatQcode ?>" /></div>
    
    <div style="margin-top: 15px;padding: 7px 12px;" id="webchatInfo">
        <p>请使用微信扫描一下二维码即可登录</p>
        <p>“悠奇”</p>
    </div>
</div>
<script type="text/javascript">
    var webChatTimeHandle = null,
        isLogined = false;
    $(function(){
        chLogin();
    })
    function chLogin(){
        var url = '<?php echo $this->validUrl ?>';
        $.ajax({
            type : 'GET',
            url : url,
            data : {code:'<?php echo $this->qcodeCode ?>'},
            dataType : 'json',
            success : function(data){
                if('201' == data.status){
                    $('#webchatInfo').html('<p>二维码已经扫描, 请确认操作即可登录');
                }else if('200' == data.status){
                    window.location.href = '/webchat/webchatback';
                    isLogined = true;
                    clearTimeout(webChatTimeHandle);
                }
            },
            complete : function(){
                if(!isLogined){
                    webChatTimeHandle = setTimeout(chLogin,5000);
                }
                
            }
        })
        
    }
    
</script>
<?php endif; ?>